package com.libgdxbar.pvzlikegame.entities;

import com.badlogic.gdx.utils.Array;

import org.libgdxbar.projects.interfaces.ILooper;

public abstract class EntitySystem implements ILooper, EntityListener {

	protected Array<Entity> entities = new Array<>();

	@Override
	public void onEntityAdded(Entity entity) {
		if (isMatch(entity)) {
			entities.add(entity);
		}
	}

	@Override
	public void onEntityRemoved(Entity entity) {
		if (isMatch(entity)) {
			entities.removeValue(entity, true);
		}
	}

	protected boolean isMatch(Entity entity){
		return true;
	}

	@Override
	public void run(float delta) {

	}

}
